package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindName {
    public static int find(BookList bookList){
        System.out.println("请输入书的名字");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();

        int usedSize = bookList.getUsedSize();

        for (int i = 0; i < usedSize; i++) {
            Book book = bookList.getPos(i);
            if (book.getName().equals(name)){
                return i;
            }
        }
        return -1;
    }

}
